home *** CD-ROM | disk | FTP | other *** search
- ' ------------------------------------------------------------------------
- '
- ' Top9.BAS -- Top 9 API Tricks
- '
- ' Copyright (C) 1993 Desaware
- '
- ' You have a royalty-free right to use, modify, reproduce and distribute
- ' this file (and/or any modified version) in any way you find useful,
- ' provided that you agree that Desaware has no
- ' warranty, obligation or liability for its contents.
- '
- ' ------------------------------------------------------------------------
- Option Explicit
-
- Global LastCommand% ' Number of latest command
-
- Type RECT '8 Bytes
- left As Integer
- top As Integer
- right As Integer
- bottom As Integer
- End Type
-
- Type POINTAPI '4 Bytes - Synonymous with LONG
- X As Integer
- Y As Integer
- End Type
-
- Type SIZEAPI '4 Bytes - Synonymous with LONG
- X As Integer
- Y As Integer
- End Type
-
- Type TASKENTRY ' 40 bytes
- dwSize As Long
- hTask As Integer
- hTaskParent As Integer
- hInst As Integer
- hModule As Integer
- wSS As Integer
- wSP As Integer
- wStackTop As Integer
- wStackMinimum As Integer
- wStackBottom As Integer
- wcEvents As Integer
- hQueue As Integer
- szModule As String * 10
- wPSPOffset As Integer
- hNext As Integer
- End Type
-
-
-
-
-
- Global Const VK_NUMLOCK = &H90
- Global Const VK_SCROLL = &H91
- Global Const VK_CAPITAL = &H14
-
-
- Global Const BITSPIXEL = 12 ' Number of bits per pixel
- Global Const PLANES = 14 ' Number of planes
-
- Global Const DT_WORDBREAK = &H10
-
- Global Const GWW_HINSTANCE = (-6)
-
- Global Const WM_USER = &H400
- Global Const EM_GETLINECOUNT = WM_USER + 10
- Global Const LB_SETTABSTOPS = (WM_USER + 19)
-
- Global Const MF_INSERT = &H0
- Global Const MF_CHANGE = &H80
- Global Const MF_APPEND = &H100
- Global Const MF_DELETE = &H200
- Global Const MF_REMOVE = &H1000
-
- Global Const MF_BYCOMMAND = &H0
- Global Const MF_BYPOSITION = &H400
-
- Global Const MF_SEPARATOR = &H800
-
- Global Const MF_ENABLED = &H0
- Global Const MF_GRAYED = &H1
- Global Const MF_DISABLED = &H2
-
- Global Const MF_UNCHECKED = &H0
- Global Const MF_CHECKED = &H8
- Global Const MF_USECHECKBITMAPS = &H200
-
- Global Const MF_STRING = &H0
- Global Const MF_BITMAP = &H4
- Global Const MF_OWNERDRAW = &H100
-
- Global Const MF_POPUP = &H10
- Global Const MF_MENUBARBREAK = &H20
- Global Const MF_MENUBREAK = &H40
-
- Global Const MF_UNHILITE = &H0
- Global Const MF_HILITE = &H80
-
- Global Const MF_SYSMENU = &H2000
- Global Const MF_HELP = &H4000
- Global Const MF_MOUSESELECT = &H8000
-
- Global Const HWND_BROADCAST = -1
-
- Global Const WM_CLOSE = &H10
- Global Const WM_WININICHANGE = &H1A
-
- Global Const PS_SOLID = 0
- Global Const PS_DASH = 1 ' -------
- Global Const PS_DOT = 2 ' .......
- Global Const PS_DASHDOT = 3 ' _._._._
- Global Const PS_DASHDOTDOT = 4 ' _.._.._
- Global Const R2_XORPEN = 7 ' DPx
- Global Const NULL_BRUSH = 5
-
- Global Const SW_HIDE = 0
- Global Const SW_SHOWNORMAL = 1
- Global Const SW_NORMAL = 1
- Global Const SW_SHOWMINIMIZED = 2
- Global Const SW_SHOWMAXIMIZED = 3
- Global Const SW_MAXIMIZE = 3
- Global Const SW_SHOWNOACTIVATE = 4
- Global Const SW_SHOW = 5
- Global Const SW_MINIMIZE = 6
- Global Const SW_SHOWMINNOACTIVE = 7
- Global Const SW_SHOWNA = 8
- Global Const SW_RESTORE = 9
-
- Global Const SRCCOPY = &HCC0020 ' (DWORD) dest = source
- Global Const SRCPAINT = &HEE0086 ' (DWORD) dest = source OR dest
- Global Const SRCAND = &H8800C6 ' (DWORD) dest = source AND dest
- Global Const SRCINVERT = &H660046 ' (DWORD) dest = source XOR dest
- Global Const SRCERASE = &H440328 ' (DWORD) dest = source AND (NOT dest )
- Global Const NOTSRCCOPY = &H330008 ' (DWORD) dest = (NOT source)
- Global Const NOTSRCERASE = &H1100A6 ' (DWORD) dest = (NOT src) AND (NOT dest)
- Global Const MERGECOPY = &HC000CA ' (DWORD) dest = (source AND pattern)
- Global Const MERGEPAINT = &HBB0226 ' (DWORD) dest = (NOT source) OR dest
- Global Const PATCOPY = &HF00021 ' (DWORD) dest = pattern
- Global Const PATPAINT = &HFB0A09 ' (DWORD) dest = DPSnoo
- Global Const PATINVERT = &H5A0049 ' (DWORD) dest = pattern XOR dest
- Global Const DSTINVERT = &H550009 ' (DWORD) dest = (NOT dest)
- Global Const BLACKNESS = &H42& ' (DWORD) dest = BLACK
- Global Const WHITENESS = &HFF0062 ' (DWORD) dest = WHITE
-
-
- Declare Function BitBlt% Lib "GDI" (ByVal hDestDC%, ByVal X%, ByVal Y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal XSrc%, ByVal YSrc%, ByVal dwRop&)
- Declare Sub ClientToScreen Lib "User" (ByVal hWnd%, lpPoint As POINTAPI)
- Declare Sub CloseWindow Lib "User" (ByVal hWnd%)
- Declare Function CreateDC% Lib "GDI" (ByVal lpDriverName$, lpDeviceName As Any, lpOutput As Any, lpInitData As Any)
- Declare Function CreatePen% Lib "GDI" (ByVal nPenStyle%, ByVal nWidth%, ByVal crColor&)
- Declare Function CreateSolidBrush% Lib "GDI" (ByVal crColor&)
- Declare Function DeleteDC% Lib "GDI" (ByVal hDC%)
- Declare Function DeleteObject% Lib "GDI" (ByVal hObject%)
- Declare Function DrawText% Lib "User" (ByVal hDC%, ByVal lpStr$, ByVal nCount%, lpRect As RECT, ByVal wFormat%)
- Declare Function FindWindowByString% Lib "User" Alias "FindWindow" (ByVal lpClassName&, ByVal lpWindowName$)
- Declare Function FindWindowByCaption% Lib "User" Alias "FindWindow" (ByVal lpClassName&, ByVal lpWindowName$)
- Declare Function FindWindowByClass% Lib "User" Alias "FindWindow" (ByVal lpClassName$, ByVal lpWindowName&)
- Declare Sub GetClientRect Lib "User" (ByVal hWnd%, lpRect As RECT)
- Declare Function GetDC% Lib "User" (ByVal hWnd%)
- Declare Function GetDeskTopWindow% Lib "User" ()
- Declare Function GetDeviceCaps% Lib "GDI" (ByVal hDC%, ByVal nIndex%)
- Declare Function GetKeyState% Lib "User" (ByVal nVirtKey%)
- Declare Function GetMenu% Lib "User" (ByVal hWnd%)
- Declare Function GetMenuCheckMarkDimensions& Lib "User" ()
- Declare Function GetMenuItemCount% Lib "User" (ByVal hMenu%)
- Declare Function GetMenuItemID% Lib "User" (ByVal hMenu%, ByVal nPos%)
- Declare Function GetModuleUsage% Lib "Kernel" (ByVal hModule%)
- Declare Function GetProfileString% Lib "Kernel" (ByVal lpAppName$, ByVal lpKeyName As Any, ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%)
- Declare Function GetStockObject% Lib "GDI" (ByVal nIndex%)
- Declare Function GetSubMenu% Lib "User" (ByVal hMenu%, ByVal nPos%)
- Declare Sub GetWindowRect Lib "User" (ByVal hWnd%, lpRect As RECT)
- Declare Function GetWindowWord% Lib "User" (ByVal hWnd%, ByVal nIndex%)
- Declare Sub InflateRect Lib "User" (lpRect As RECT, ByVal X%, ByVal Y%)
- Declare Function ModifyMenu% Lib "User" (ByVal hMenu%, ByVal nPosition%, ByVal wFlags%, ByVal wIDNewItem%, ByVal lpString As Any)
- Declare Function ModifyMenuBynum% Lib "User" Alias "ModifyMenu" (ByVal hMenu%, ByVal nPosition%, ByVal wFlags%, ByVal wIDNewItem%, ByVal lpString&)
- Declare Function ModifyMenuBystring% Lib "User" Alias "ModifyMenu" (ByVal hMenu%, ByVal nPosition%, ByVal wFlags%, ByVal wIDNewItem%, ByVal lpString$)
- Declare Function PostMessageBynum% Lib "User" Alias "PostMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam&)
- Declare Function Rectangle% Lib "GDI" (ByVal hDC%, ByVal X1%, ByVal Y1%, ByVal X2%, ByVal Y2%)
- Declare Function ReleaseDC% Lib "User" (ByVal hWnd%, ByVal hDC%)
- Declare Sub ScreenToClient Lib "User" (ByVal hWnd%, lpPoint As POINTAPI)
- Declare Function SelectObject% Lib "GDI" (ByVal hDC%, ByVal hObject%)
- Declare Function SendMessageBynum& Lib "User" Alias "SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam&)
- Declare Function SendMessage& Lib "User" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, lParam As Any)
- Declare Function SendMessageByString& Lib "User" Alias "SendMessage" (ByVal hWnd%, ByVal wMsg%, ByVal wParam%, ByVal lParam$)
- Declare Function SetCapture% Lib "User" (ByVal hWnd%)
- Declare Function SetROP2% Lib "GDI" (ByVal hDC%, ByVal nDrawMode%)
- Declare Sub SetWindowText Lib "User" (ByVal hWnd%, ByVal lpString$)
- Declare Function TaskFirst% Lib "Toolhelp.dll" (lpTask As TASKENTRY)
- Declare Function TaskNext% Lib "Toolhelp.dll" (lpTask As TASKENTRY)
- Declare Function WinExec% Lib "Kernel" (ByVal lpCmdLine$, ByVal nCmdShow%)
- Declare Function WriteProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpString$)
-
- Function FormattedHex$ (value%, length%)
- Dim f$
- f$ = Hex$(value%)
- While (Len(f$) < length%)
- f$ = "0" & f$
- Wend
- FormattedHex$ = f$
-
- End Function
-
- Function NullTermToVBString$ (usestr$)
- Dim position%
- position% = InStr(usestr, Chr$(0))
- If position% <= 1 Then
- NullTermToVBString$ = ""
- Exit Function
- End If
- NullTermToVBString$ = Left$(usestr$, position% - 1)
-
- End Function
-
- Function NumberOfColors& (ByVal hDC%)
- Dim numplanes%, numbitspixel%
- Dim numcolors&
- numplanes% = GetDeviceCaps%(hDC, PLANES)
- numbitspixel% = GetDeviceCaps%(hDC, BITSPIXEL)
- ' Left shift operation
- numcolors& = 2 ^ (numplanes% * numbitspixel%)
-
- NumberOfColors& = numcolors&
-
- End Function
-
- '
- ' Extracts the idx%'th string from source$, where the substrings
- ' are separated by character sep$
- '
- Function ParseAnyString$ (source$, ByVal idx%, ByVal sep$)
- Dim nexttab%, basepos%, thispos%
- Dim res$
- basepos% = 1
- thispos% = 0
- If (Len(source$) = 0) Then
- ParseAnyString$ = ""
- Exit Function
- End If
- Do
- nexttab% = InStr(basepos%, source$, sep$)
- If nexttab% = 0 Then nexttab% = Len(source$) + 1
- ' Now points to next tab or 1 past end of string
- ' The following should never happen
- ' If nexttab% = basepos% Then GoTo ptsloop1
-
- If thispos% = idx% Then
- If nexttab% - basepos% - 1 < 0 Then
- res$ = ""
- Else
- res$ = Mid$(source$, basepos%, nexttab% - basepos%)
- End If
- Exit Do
- End If
- ptsloop1:
- basepos% = nexttab% + 1
- thispos% = thispos% + 1
- Loop While (basepos% <= Len(source$))
- ParseAnyString$ = res$
-
-
- End Function
-
-